﻿Imports SlimDX.Direct3D9


Public Class ShaderMeter
    Implements IShader
    Dim Base As Texture

    Dim flags As Short

    Sub New(ByVal sglaTag As Magic.Core.Tag)

        AddHandler sglaTag.TagHasChanged, AddressOf Changed

        Dim BaseIndex = sglaTag("map")

        flags = sglaTag(12)

        If BaseIndex > -1 Then
            Base = New Bitmap(magicMap.Library(BaseIndex)).Texture
        End If
    End Sub
    Sub Changed(ByVal sglaTag As Magic.Core.Tag)

        Dim BaseIndex = sglaTag("map")

        flags = sglaTag(12)

        If BaseIndex > -1 Then
            Base = New Bitmap(magicMap.Library(BaseIndex)).Texture
        End If
    End Sub
    Public Overloads Sub BeginPass(ByVal pass As Integer) Implements IShader.BeginPass
        shaderEffect.BeginPass(pass)
    End Sub
    Public Overloads Sub EndPass() Implements IShader.EndPass
        shaderEffect.EndPass()
    End Sub

    Public Overloads Function BeginShader(ByVal tLightmap As Texture) As Integer Implements IShader.BeginShader


        shaderEffect.SetTexture("diffuse", Base)
        shaderEffect.Technique = "meter"
        Return shaderEffect.Begin(FX.DoNotSaveState)
    End Function
    Public Overloads Sub EndShader() Implements IShader.EndShader
        shaderEffect.End()
    End Sub
End Class
